package net.tv90.bfmccoreqqbot.api.handler;

import net.tv90.bfmccore.api.info.ServerInfo;
import net.tv90.bfmccoreqqbot.api.MessageHandler;
import net.tv90.bfmccoreqqbot.api.annotation.MessageCheck;
import net.tv90.bfmccoreqqbot.api.annotation.MessageCheckPolicy;
import net.tv90.bfmccoreqqbot.api.annotation.MessageType;
import net.tv90.bfmccoreqqbot.api.entity.MessageContext;


@MessageType("查服")
@MessageCheck(MessageCheckPolicy.EQUALS)
public class ServerInfoMessageHandler implements MessageHandler {

    @Override
    public String handleMessage(MessageContext msg) {

        System.out.println(msg.getSenderNickname() + ": " + msg.getMessage());

        if (ClearCoolDownMessageHandler.enableCoolDown && !ClearCoolDownMessageHandler.coolDownQqIdBypassList.contains(msg.getSenderQq())) {
            ClearCoolDownMessageHandler.coolDownQqIdList.add(msg.getSenderQq());
        }

        return ServerInfo.getServerInfo();
    }

    @Override
    public boolean onPreHandleMessage(MessageContext msg) {
        System.out.println("接受到消息: " + msg.getMessage());
        return !ClearCoolDownMessageHandler.enableCoolDown || !ClearCoolDownMessageHandler.coolDownQqIdList.contains(msg.getSenderQq());
    }
}
